package com.sunny.client.loadbalance;

import java.util.List;

/**
 * 模板方法实现负载均衡
 *
 * @author Sunny
 * @date 2020/2/16
 */
public abstract class AbstractLoadBalance implements LoadBalanceStrategy {

    @Override
    public String selectHost(List<String> address) {
        if (address == null || address.isEmpty()) {
            return null;
        }
        if (address.size() == 1) {
            return address.get(0);
        }
        return doSelectHost(address);
    }

    protected abstract String doSelectHost(List<String> address);
}
